package org.emet.entity.storage;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.emet.jee.console.entity.BaseEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 销售记录
 * 
 * @author alex
 * 
 */
@Entity
@Table(name = "T_SALE_HIST")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SaleHist extends BaseEntity {
	private String flowNo;
	private String customer;
	private String operatorSN;
	private String operatorName;
	private List<SaleItem> items;
	private Date date = new Date();

	public String getFlowNo() {
		return flowNo;
	}

	public void setFlowNo(String flowNo) {
		this.flowNo = flowNo;
	}

	/*
	 * @ManyToOne
	 * 
	 * @JoinColumn(name = "customer_id") public Customer getCustomer() { return
	 * customer; }
	 * 
	 * public void setCustomer(Customer customer) { this.customer = customer; }
	 */

	public String getOperatorSN() {
		return operatorSN;
	}

	public String getCustomer() {
		return customer;
	}

	public void setCustomer(String customer) {
		this.customer = customer;
	}

	public void setOperatorSN(String operatorSN) {
		this.operatorSN = operatorSN;
	}

	public String getOperatorName() {
		return operatorName;
	}

	public void setOperatorName(String operatorName) {
		this.operatorName = operatorName;
	}

	@OneToMany(mappedBy = "saleHist", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@Fetch(FetchMode.SUBSELECT)
	public List<SaleItem> getItems() {
		return items;
	}

	public void setItems(List<SaleItem> items) {
		this.items = items;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	
}
